<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/inc/taglibs.jsp"%>

<SCRIPT type="text/javascript">
$("#saveEntity").click(function(){
	var treeObj = $.fn.zTree.getZTreeObj("groupAuthTree");
	var nodes = treeObj.getCheckedNodes(true);
	var moduleid = '';
	for(var i=0;i<nodes.length; i++){
		var treeNode = nodes[i];
		moduleid = moduleid + ',' + treeNode.id;
	}
	$("#i_moduleids").val(moduleid);
	$.ajax({
		cache: true,
		type: "POST",
		url: $('#entityForm').attr('action'),
		data:$('#entityForm').serialize(),
		async: false,
		error: function(error) {
		    alert("Connection error");
		},
		success: function(data) {
		    $("#main_main").html(data);
		}
	});
});


var setting = {
	check: {
		enable: true
	},
	data: {
		simpleData: {
			enable: true
		}
	}
};
function refreshGroupAuthTree(){
	$.getJSON(siteServer + "/rms/group/getAuthTree.do?groupid="+$("#group_id").val(), function(zNodes){
		$.fn.zTree.init($("#groupAuthTree"), setting, zNodes);
	});
}
$(document).ready(function(){
	refreshGroupAuthTree();
});
</SCRIPT>
<form id="entityForm" name="entityForm" action="<c:url value='/rms/group/save.do'/>">
	<input type="hidden" id="group_id" name="id" value="${entity.id}"/>
	<input type="hidden" id="i_moduleids" name="moduleids" value=""/>
	<table class="tableform" width="100%" cellspacing="0" cellpadding="0" border="0">
		<tbody>
		<tr>
			<td width="17%">
				组名称：
				<font color="red">*</font>
			</td>
			<td width="83%">
				<div>
				<input id="groupName" class="w200" type="text" name="groupName" value="${entity.groupName}">
				<span class="error_msg" style="display: inline;"> </span>
				</div>
			</td>
		</tr>
		<tr>
			<td width="17%">
				备注：
				<font color="red">*</font>
			</td>
			<td width="83%">
				<div>
				<textarea id="remark" class="w200" name="remark"">
					<c:out value="${entity.remark}"></c:out>
				</textarea>
				<span class="error_msg" style="display: inline;"> </span>
				</div>
			</td>
		</tr>
		<tr>
			<td colspan="2">
				<ul id="groupAuthTree" class="ztree"></ul>
			</td>
		</tr>
		<tr>
			<td colspan="2">
			<input id="saveEntity" class="btn Borange fw7 mb20" type="button" value="保   存">
			</td>
		</tr>
		</tbody>
	</table>
</form>
